$(function () {
   // 搜素功能
   let flag = true // 节流阀
   $('#mws-container .btn-search').on('click', function () {
      if (!flag) return
      const pwd = $(this).siblings('input').val()
      flag = false // 开启节流
      $.get(`/homeuser/usersearch?pwd=${pwd}`, data => {
         const { msg, status, data: arr } = data
         if (msg === 'ok' && status === 200) {
            let html = ''
            arr.forEach((v, i) => {
               html += `
                  <tr class="${i % 2 ? 'odd' : 'even'}" align="center">
                     <td class="sorting_1">${i + 1}</td>
                     <td>${v.username}</td>
                     <td data-uid="${v.id}">
                        <a class="btn btn-small btn-primary btn-userinfo" href="/homeuser/userinfo?uid=${v.id}">
                           <i class="icon-list-2"></i>
                        </a>
                        <a class="btn btn-small btn-warning btn-address" href="/homeuser/useraddress?uid=${v.id}">
                           <i class="icon-truck"></i>
                        </a>
                     </td>
                  </tr>
                `
            })
            $('#mws-container tbody').html(html)
            if (arr.length === 0) {
               $('.container .btn-normal').css('display','block')
            } else {
               $('.container .btn-normal').css('display', 'none')
            }
            // 关闭节流
            setTimeout(() => {
               flag = true
            }, 2000)
         }
      })
   })
   $('#mws-container .dataTables_filter input').keydown((e) => {
      if (e.code !== 'Enter') return
      $('#mws-container .btn-search').trigger('click')
   })

   /* 分页器 */
   

})